package com.itheima.exer.exercise.ex0925;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/**
 * 今日案例[API]:老版本日期转换/新版本日期的转换[3]
 * /在原基础增加日期/在原基础上修改日期/自定义异常
 */
public class OldDate {
    public static void main(String[] args) throws ParseException {
        System.out.println("请输入您的出生年月:");
        String birthday = new Scanner(System.in).nextLine();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse(birthday);
        Date date = new Date();
        String format = simpleDateFormat.format(date);
        long time = Math.abs(parse.getTime()-date.getTime());
        long day = time/1000/60/60/24;
        System.out.println("从"+birthday+"到"+format+"您已经活了"+day+"天了");
    }
}
